import { RouteRecordRaw } from "vue-router";
import HomeView from "@/views/HomeView.vue";
import AdminView from "@/views/AdminView.vue";
import NoAuth from "@/views/NoAuth.vue";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLogin from "@/views/user/UserLogin.vue";
import UserRegister from "@/views/user/UserRegister.vue";
import accessEnum from "@/access/accessEnum";
import TestView from "@/views/TestView.vue";
import MdEditor from "@/components/MdEditor.vue";
import CodeEditor from "@/components/CodeEditor.vue";
import AddQuestion from "@/views/question/AddQuesstionView.vue";
import ManageQuestion from "@/views/question/ManageQuestionView.vue";
import Questions from "@/views/question/QuestionView.vue";
import QuestionDetail from "@/views/question/QuestionDetailView.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    children: [
      {
        path: "/user/login",
        name: "登录",
        component: UserLogin,
      },
      {
        path: "/user/register",
        name: "注册",
        component: UserRegister,
      },
    ],
    meta: {
      hide: true,
    },
  },
  {
    path: "/",
    name: "题目模块",
    component: Questions,
  },
  {
    path: "/add/question",
    name: "添加题目",
    component: AddQuestion,
    meta: {
      //access: accessEnum.ADMIN,
    },
  },
  {
    path: "/update/question",
    name: "修改题目",
    component: AddQuestion,
    meta: {
      hide: true,
      access: accessEnum.ADMIN,
    },
  },
  {
    path: "/questions",
    name: "题目列表",
    component: Questions,
    meta: {
      //access: accessEnum.ADMIN,
    },
  },
  {
    path: "/manage/question",
    name: "管理题目",
    component: ManageQuestion,
    meta: {
      //access: accessEnum.ADMIN,
    },
  },
  {
    path: "/view/question/:id",
    name: "题目详情",
    component: QuestionDetail,
    props: true,
    meta: {
      access: accessEnum.USER,
      hide: true,
    },
  },
  {
    path: "/about",
    name: "关于我",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
  {
    path: "/admin",
    name: "后台管理模块",
    component: AdminView,
    meta: {
      access: accessEnum.ADMIN,
    },
  },
  {
    path: "/403",
    name: "403",
    component: NoAuth,
    meta: {
      hide: true,
      access: accessEnum.NOT_LOGIN,
    },
  },
  {
    path: "/test",
    name: "test",
    component: TestView,
    meta: {
      hide: true,
      access: accessEnum.NOT_LOGIN,
    },
  },
  {
    path: "/md",
    name: "md",
    component: MdEditor,
    meta: {
      hide: true,
      access: accessEnum.NOT_LOGIN,
    },
  },
  {
    path: "/code",
    name: "code",
    component: CodeEditor,
    meta: {
      hide: true,
      access: accessEnum.NOT_LOGIN,
    },
  },
];
